BotBuilder-schema contains the serialized data sent across the wire between user and bot when using Bot Framework
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Semantic entity models for representing structured data like mentions, places, geographic coordinates, and generic schema.org entities within Bot Framework activities.
The base class for all semantic entities attached to activities.
class Entity(Model):
def __init__(self, *, type: str = None, **kwargs):
"""
Metadata object pertaining to an activity.
Parameters:
- type: Type of this entity (RFC 3987 IRI)
"""from botbuilder.schema import Entity
# Create a generic entity
entity = Entity(type="https://schema.org/Person")Schema.org GeoCoordinates entity for representing geographic locations.
class GeoCoordinates(Model):
def __init__(self, *, elevation: float = None, latitude: float = None,
longitude: float = None, type: str = None, name: str = None, **kwargs):
"""
GeoCoordinates (entity type: "https://schema.org/GeoCoordinates").
Parameters:
- elevation: Elevation of the location [WGS 84](https://en.wikipedia.org/wiki/World_Geodetic_System)
- latitude: Latitude of the location [WGS 84](https://en.wikipedia.org/wiki/World_Geodetic_System)
- longitude: Longitude of the location [WGS 84](https://en.wikipedia.org/wiki/World_Geodetic_System)
- type: The type of the thing
- name: The name of the thing
"""from botbuilder.schema import GeoCoordinates
# Create geographic coordinates for a location
coords = GeoCoordinates(
latitude=47.6062,
longitude=-122.3321,
elevation=56.0,
type="https://schema.org/GeoCoordinates",
name="Seattle, WA"
)Schema.org Place entity for representing physical locations with addresses and coordinates.
class Place(Model):
def __init__(self, *, address=None, geo=None, has_map=None,
type: str = None, name: str = None, **kwargs):
"""
Place (entity type: "https://schema.org/Place").
Parameters:
- address: Address of the place (may be `string` or complex object of
type `PostalAddress`)
- geo: Geo coordinates of the place (may be complex object of type
`GeoCoordinates` or `GeoShape`)
- has_map: Map to the place (may be `string` (URL) or complex object
of type `Map`)
- type: The type of the thing
- name: The name of the thing
"""from botbuilder.schema import Place, GeoCoordinates
# Create a place with address and coordinates
place = Place(
name="Microsoft Campus",
address="One Microsoft Way, Redmond, WA 98052",
geo=GeoCoordinates(
latitude=47.6394,
longitude=-122.1282,
type="https://schema.org/GeoCoordinates"
),
type="https://schema.org/Place"
)The most generic Schema.org entity representing any "thing" that can be named and typed.
class Thing(Model):
def __init__(self, *, type: str = None, name: str = None, **kwargs):
"""
Thing (entity type: "https://schema.org/Thing").
Parameters:
- type: The type of the thing
- name: The name of the thing
"""from botbuilder.schema import Thing
# Create a generic thing entity
thing = Thing(
type="https://schema.org/Organization",
name="Microsoft Corporation"
)from botbuilder.schema import (
Activity, ActivityTypes, Entity, Place, GeoCoordinates
)
# Create an activity with location entities
activity = Activity(
type=ActivityTypes.message,
text="I'm currently at the Microsoft campus.",
entities=[
Place(
name="Microsoft Campus",
address="One Microsoft Way, Redmond, WA 98052",
geo=GeoCoordinates(
latitude=47.6394,
longitude=-122.1282
),
type="https://schema.org/Place"
)
]
)from botbuilder.schema import GeoCoordinates, Place
def create_location_entity(name: str, lat: float, lng: float, address: str = None):
"""Create a location entity with coordinates."""
coords = GeoCoordinates(
latitude=lat,
longitude=lng,
type="https://schema.org/GeoCoordinates"
)
return Place(
name=name,
address=address,
geo=coords,
type="https://schema.org/Place"
)
# Usage
seattle = create_location_entity(
"Seattle",
47.6062,
-122.3321,
"Seattle, WA, USA"
)from botbuilder.schema import Entity
# Create custom schema.org entities
person_entity = Entity(type="https://schema.org/Person")
product_entity = Entity(type="https://schema.org/Product")
event_entity = Entity(type="https://schema.org/Event")
# Entities can be added to activities for semantic enrichment
activity.entities = [person_entity, product_entity, event_entity]All entity classes follow Schema.org standards for structured data representation, enabling rich semantic understanding of bot conversations. The type field uses Schema.org IRIs to define the semantic meaning of entities.
Common Schema.org entity types used in bot scenarios:
https://schema.org/Person - People and individualshttps://schema.org/Organization - Companies and organizationshttps://schema.org/Place - Physical locationshttps://schema.org/Event - Events and activitieshttps://schema.org/Product - Products and serviceshttps://schema.org/GeoCoordinates - Geographic coordinatesInstall with Tessl CLI
npx tessl i tessl/pypi-botbuilder-schema