Skip to content

janhofmann01/Watson-assistant-discord-webhooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Make Watson Assistant send messages to your Discord Server

In this workshop we are going to connect Watson Assistant to a Discord Webhook, which allows us to send messages from our Assistant to a Discord textchannel.

Overview

In this workshop we are going to:

  1. Set up a Discord webhook
  2. Set up an IBM cloud function to call our webhook
  3. Set up our Assistant, and connect it to the cloud function

Prerequisites

  1. Sign up for an IBM Cloud account.
  2. Fill in the required information and press the „Create Account“ button.
  3. After you submit your registration, you will receive an e-mail from the IBM Cloud team with details about your account. In this e-mail, you will need to click the link provided to confirm your registration.
  4. Now you should be able to login to your new IBM Cloud account ;-)
  5. Create a Discord account, as well your own Discord server (both are free of charge).

1. Activate Webhooks in Discord

We want to enable webhooks in our Discord server's settings, which will be used by Watson Assistant to send messages.

  1. Go to your server's settings
  2. Navigate to Integrations
  3. Create a new Webhook, and copy its URL

Note: Discord does not require any additional Authentification, which means that anyone who has the URL can use the Webhook. Ensure that only you, and people you trust have access to it.

2. Set up your cloud function

We could use the Discord webhook directly, but since Discord sends us an empty response on success, our assistant wouldn't be able to verify, wether the message was sent correctly or not.

Create cloud function

We want to set up a cloud function, which Watson Assistant will be able to access. To do that, you need to go to your IBM Cloud Dashboard, and select Functions.

Alternatively you can click here to access the IBM Cloud functions.

Now you can create a new Action. Give it a sensible name, select python as your runtime, and click create.

Create Cloud Function Action

Paste in the code that can be found here, change the value of discordurl to your URL, and save your changes.

Test cloud function

If you want to test it, you can click on Invoke with parameter, paste in the input below, click apply, and press Invoke.

{
    "content" : "this is a test message sent by your cloud function"
}

If the message was sent successfully, the result should look like this.

Enable as Web Action

Now we need to create an endpoint, which will be used by Watson Assistant to invoce your function.

On the left side, click Endpoints and check the box called Enable as Web Action. Press save, and copy the URL.

3. Set up your Assistant

Set up Watson Assistant

Go back to your Dashboard, and type Watson Assistant into the search bar. If you already have a Watson Assistant service you can use it, otherwise you can create a free lite version either by clicking Watson Assistant under the Catalog Results Section or following this link.

Create your own Skill

Afterwards launch your Watson Assistant Service, and look for Skills on the left.

If you can't find it, click on the profile icon in the upper right corner, and click Switch to classic experience.

Create a new skill, select Dialog skill and click next. Select Upload skill and provide the skill-Connect-to-Discord.json file.

Enable Webhooks

Before you can test your assistant, you need to provide the cloud funtion's URL.

Click on Options->Webhooks, paste in the URL, and ADD A .json AT THE END.

We could use Discord's webhook link direcly, without adding a .json, and it would send the message as well. However, Discord doesn't return anything (that Watson Assistant can understand), which would prevent us from informing the user of our assistant, that the message was sent correctly.

Test your assistant

Now you can click on the Try it button and test whether the assistant is working correctly.


About

This workshop is part of the "IBM Cloud & Watson Intro" Series: https://github.com/FelixAugenstein/ibm-cloud-watson-intro

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages