Build With MultiOn

Order on Amazon with MultiOn

This example combines MultiOn browse and local mode to purchase a book on Amazon.

Project setup

Install extension

Find the MultiOn Browser Extension on the Chrome Web Store and click “Add to Chrome” to add it to your browser. Make sure the API Enabled option is checked. Learn more about the browser extension here.

Initialize project

Create a new project by running the following command in your terminal:

$npm init

Install package

Install the multion package by running the following command in your terminal:

$npm install multion

Import library

Create a new file called index.ts and import the required library for the example:

1import { MultiOnClient } from 'multion';

Initialize client

Initialize the MultiOn client with your API key.

1const multion = new MultiOnClient({ apiKey: "YOUR_API_KEY" });

Run script

Run your script by running the following command in your terminal:

$node index.ts

Add book to cart

Use browse in local mode to add the book to your shopping cart.

1const cartResponse = await multion.browse({
2 cmd: "Add the Three Body Problem book to my cart",
3 url: "https://amazon.com",
4 local: true
5});
6
7console.log(cartResponse.message);

Buy the book!

Now, if you want to buy the book, continue the same session to complete the purchase.

1const sessionId = followResponse.sessionId
2
3const purchaseResponse = await multion.browse({
4 sessionId: sessionId,
5 cmd: "Check out and purchase the book"
6});
7
8console.log(purchaseResponse.message);