Code Monkey home page Code Monkey logo

fancyhands's Introduction

fancyhands-python

Python library for the Fancy Hands API. Full documentation for the API lives on github.

Version

0.1

Requirements

Installation

Just copy the fancyhands-python/fancyhands directory to your project or:

pip install fancyhands

or

git clone https://github.com/fancyhands/fancyhands-python
cd fancyhands-python
python setup.py install

Usage

Dealing with 'custom' requests
from fancyhands import FancyhandsClient

api_key = 'your_api_key'
secret = 'your_api_secret'

client = FancyhandsClient(api_key, secret)

# Get last 20 requests
requests = client.custom_get()

# Create a new custom request
from datetime import datetime, timedelta

title = 'Call Nicholas'
description = 'Tell him to make me some toast.'
bid = 4.0
expiration_date = datetime.now() + timedelta(1)

custom_fields = []
custom_field = {
  'label':'Response',
	'type':'textarea',
	'description':'When will my toast be done?',
	'order':1,
	'required':True,
}
custom_fields.append(custom_field)

request = client.custom_create(title, description, bid, expiration_date, custom_fields)

# Create a new standard request
title = "Call Ted"
description = "Tell him his toast is ready"

request = client.standard_create(title=title, description=description, bid=bid, expiration_date=expiration_date)

# Get a standard request
request = client.standard_get(key=request['key'])

# Message a standard request
client.standard_message(key=request['key'], message="Is the toast done yet")

# Create a new call request
# Visit: https://www.fancyhands.com/api/explorer/script/builder#/start
# Create a script for the assistant and paste it into your code
import json
conversation = json.dumps({"id":"sample_conversation","data":{},"name":"Sample Conversation","version":1.1,"scripts":[{"id":"start","steps":[{"name":"hello","type":"logic_control","note":"","prompt":"Hello, my name is $assistant_name","options":[{"name":"Continue","result":"sample_script"}]}]},{"id":"sample_script","steps":[{"name":"name","prompt":"What is your name?","type":"text","options":[]},{"name":"quest","prompt":"What is your quest?","type":"textarea","options":[]},{"type":"logic_control","name":"favorite_color","note":"","options":[{"name":"Red","result":"finish"},{"name":"Yellooooooooooooow","result":"finish","new_script":""},{"name":"Blue","result":"transfer"}],"prompt":"What is your favorite color?"}]},{"id":"finish","steps":[{"type":"logic_control","name":"goodbye","note":"","prompt":"Thank you $sample_script.name. I wish you good luck with $sample_script.quest.","options":[]}]},{"id":"transfer","steps":[{"type":"logic_control","name":"transfer","note":"","prompt":"$sample_script.favorite_color!!!? I wasn't expecting that... Please hold while I transfer you to my manager.","options":[{"name":"Transfer Call","result":"-- Transfer Call --"}]}],"transfer_number":"5555555555"}]})

# Add a valid US phone number
phone = '5555555555'

# Should we retry the call? This is not required
retry = True

# Retry every two hours
retry_delay = 60 * 60 * 2

# How many times to retry the call
retry_limit = 3

request = client.call_create(phone=phone, conversation=conversation, retry=retry, retry_delay=retry_delay, retry_limit=retry_limit)

License

MIT

fancyhands's People

Contributors

joseph-zhong avatar

Watchers

 avatar  avatar

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.