YelpBaaS Bot

ServisBOT BaaS is the home for mappings between the ServisBOT platform and external services such as APIs and SDKs. The easiest way to see the power of a BaaS is build one using our out-of-the box blueprints, and build a demo bot.

Blueprints can contain more than just one ServisBOT bot building block. There are blueprints for Just BaaS items, or just bots with workers, and then there are also blueprints with all three.

Yelp Search BOT

In this example we will walk you through the steps to create and test a Yelp BaaS API connector, then extend a basic classic flow conversation with it.

Requirements

Build a Classic Flow Bot from Blueprint

  1. Go to the Bot Designer
    1. Click on Create BOT
  2. Select the “Classic Flow Bot Blueprint”
    1. Name this bot RestaurantBot
    2. Enter anything for the description
    3. For the welcome message, we want to let the user know that this bot can help them find a restaurant Hi, how can I help?
  3. Click create
    1. If building was successful, click complete.
    2. We will come back to this area later.

Build a Yelp BaaS from Blueprints

  1. First set up your secret, containing your API Token
    1. You’ll need to create a Yelp Fusion API keys
    2. Go to Secrets Management in portal
    3. Click Create
    4. Select the Token API Template from the creation page
    5. Replace APIKEY with your Yelp key
    6. Hit save
  2. Time to move on to creating the API Connector
    1. Go to BaaS API Connectors
    2. Click on Create
    3. Select the Yelp Business Directory
    4. Enter an Alias for the connector. Suggested businessSearch
    5. From the secrets dropdown, select your recently created secret
    6. Create Connector will save all of your settings into the platform.

Wire up your bot to the BaaS

  1. Go back to the Bot Army section of portal and find your bot.
  2. Click on your RestaurantBot
  3. On the bot’s detail page there will be a button up at the top labeled Designer which will take you to the Classic flow canvas.
  4. Your Flow will start off looking like this:
  5. We will begin by editing the purple prompt node
    1. double click the purple node
    2. Add a new option for Find me a restaurant, restaurants
    3. After Clicking done, there will be a new 5th output on the node
  6. Drag and drop a BaaS node onto the Canvas
    1. Name it yelp business Search
    2. Edit the context fields
    3. Connect up the fifth output to the BaaS node
  7. Process the ResponseMapping
    1. Drop a function node onto the canvas
    2. in the function body assign the BaaS response to a messenger variable msg.payload.foodPlaces = msg.baas.businessSearch.response.businesses; return msg;
  8. Set up the markup template
    1. We will use a carousel to display the yelp template
    2. Drop Template Node on to the canvas
    3. Edit the node
      1. Set property to msg.foodPlaces
      2. Set Format to Mustache Template
      3. Set output to Plain text
      4. add in the following markup.
<TimelineMessage minimumDisplayTime="5">
  <List title="Select a restaurant" horizontal="true" selectable="true" style="large-icon">
    {{# payload.foodPlaces }}
    <Item title="{{name}}" subtitle="" id="1" imageUrl="https://res.cloudinary.com/sb-botbuilders/image/fetch/w_200,h_128,c_fill,g_face,r_20,f_auto/{{image_url}}">
      <Option title="Reserve" id="Reserve"/>
      <Option title="Details" url="{{url}}" urlTitle="See Restaurant Details"/>
    </Item>
    {{ / payload.foodPlaces }}
  </List>
</TimelineMessage>

Setup the return message and finish wiring

  1. Drop a markup node onto the Canvas
  2. Name it, and edit the message to be msg.foodPlaces
  3. Wire the output to back to the prompt node
  4. Deploy and test
    1. Click Deploy in the canvas and navigate back to the bot pages
    2. From the bottom of the test page you can open up a preview window.
    3. Now when the bot displays the menu, you can select Find me a restaurant You bot should send you a list of restaurants in a carousel.