LogoLogo
  • Introduction to the Ebbot Platform
  • Ebbot Platform
  • Bot basics
    • Scenarios
    • Entities
    • Triggers
    • Training center
  • Scenarios
    • Cards and syntax
      • File Input
      • Text card
      • Input
      • Buttons
      • Image
      • File
      • Carousel
      • Location
      • List
      • Contact Agent
      • Rating request
      • Custom component
      • CoBrowsing
    • Transition
    • Card properties
  • AI Insights
    • Setup and Configuration
    • Using the Insights Dashboard
  • EbbotGPT
    • Knowledge
      • Data source transformer
      • Source types
        • File
        • Website scrape
        • Docx file
        • TOPdesk API
        • Sitevision API
        • SharePoint API
          • Create app with Sites.FullControl.All permission in Azure
          • Ebbot SharePoint Postman Guide
        • Confluence API
    • Configurations
    • Persona
    • GPT Evaluation
    • Embedder models
    • EGPT models
  • Custom vocabulary
  • Tutorials
    • Create your first scenario
      • Select a trigger
      • Add bot responses
  • Data Object
  • Release notes
  • For developers
    • Ebbot SDK
    • Safe Exchange API / Vault
    • Subdomain manager
  • EbbotGPT API
  • Chatbot & Live chat
    • Install chat widget
    • Chats API
    • Chat widget API
    • Datasource API
    • Sales tracking for live chat
    • Webhook
      • Incoming webhooks
      • Outgoing webhooks
    • SMS API
      • Authentication
      • Send SMS
      • Errors
      • Encoding
    • Python components
    • Intent detection (NLP)
  • Product guides
    • Product data feeds
    • Install guide
    • Product guide events
      • Product guide user events
      • Received events
      • Send events
    • API & webhooks
    • GA4 integration
    • Klaviyo integration
  • Messenger marketing
    • Install popup
    • API & webhooks
  • For chat agents
    • Ebbot Chat
      • Settings modal
      • Queue
      • Topbar Stats
      • Menu
        • Power-Ups!
        • Quick Replies
  • INTEGRATIONS
    • Ebbot Live Chat in Zendesk
      • Setup guide
    • Active Directory - SAML
    • Configure SAML in Azure
Powered by GitBook
On this page
  • Passing data to python component
  • test_component.py
  • test_store_data.py
  • Custom dependencies

Was this helpful?

  1. Chatbot & Live chat

Python components

Note:

Deploying custom components in Ebbot is currently only available to Ebbot developers, however this documentation can be used to locally recreate the data object that all components bases its functionality on. If you have created a component you would like to use in Ebbot, reach out to helpme@ebbot.ai and we'll help you set it up.

You are able to pass data from your scenario to a custom component, where it can be processed and then returned to the scenario, or if you like, trigger another scenario or state. Custom components are useful for calling an external API, creating a ticket, or passing data to your own systems.

Passing data to python component

Create a new state and give your component a name. In the example below we named the component test_component You can pass as many variables as you like to the component.

[
    {
        "name": "state_1",
        "component": "test_component",
        "properties": {
            "key": "value1",
            "key2": "value2"
        }
    }
]

test_component.py

The following component collects data from the scenario and returns a text response to the chat.

def main(data):

    ## 1. Collecting data from scenario
    variableOne = data['properties']['key'] ## value1
    variableTwo = data['properties']['key2'] ## value2

    ## 2. Write some magic code

    ## 3. Returning a component to the scenario
    return
    {
        "component": "ebbot_text",
        "properties": {
            "text": variableTwo
        }
    }

test_store_data.py

The following component returns data, making it accessible from a scenario or other custom components.

def main(data):

    ## 1. Collecting data from scenario
    variableOne = data['db']['key'] ## value1

    ## 2. New variable to pass into scenario
    variableTwo = "Some data that should be accessed from the chat"

    ## 3. Write some magic code

    ## 4. Returning a variable to the scenario
    return
    {
        "database": {
            "key2": variableTwo
        }
    }

Note! You need to write your code for python 3.4 or later.

Custom dependencies

You can easily add your own python dependencies by adding them to the requirements tab. This is useful if you want to add a python package to your bot or if you want to re-use code.

requests
numpy
scrapy

You need to import the package into the python code to use it

import requests
import numpy
import scrapy
PreviousEncodingNextIntent detection (NLP)

Last updated 4 months ago

Was this helpful?