Coder Social home page Coder Social logo

janhofmann01 / watson-assistant-discord-webhooks Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 282 KB

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

License: Apache License 2.0

Python 100.00%

watson-assistant-discord-webhooks's Introduction

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.


watson-assistant-discord-webhooks's People

Contributors

janhofmann01 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

felixaugenstein

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.